﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using DDOS.Objects;

namespace DDOS.Game_State
{
    class LevelLayer : ScreenLayer
    {
        protected List<Room> rooms;
        public bool intransition;
        private Color transColor;
        private Transit transitType;
        public bool halfway;
        public Room curRoom;
        public Room nextRoom;

        public LevelLayer() : base(false)
        {
            halfway = false;
            transitType = Transit.BEGIN;
            transColor = Color.Black;
            transColor.A = 0;
            intransition = false;
            rooms = new List<Room>();
        }

        

        public override void Update(GameTime gt)
        {
            foreach (Room r in rooms)
                r.Update(gt);
            
            if (intransition && transitType == Transit.BEGIN)
            {
                
                transColor.A += 5;
                if (transColor.A >= (byte)250)
                {
                    
                    transColor.A = byte.MaxValue;
                    halfway = true;
                    transitType = Transit.END;
                }
            }
            else if (intransition && transitType == Transit.END)
            {
                
                transColor.A -= 5;
                if (transColor.A <= (byte)10)
                {
                    transColor.A = byte.MinValue;
                    intransition = false;
                    transitType = Transit.BEGIN;
                    
                    
                }
            }
        }
        public override void Draw()
        {
            
            curRoom.Draw();
            
            if (intransition)
            {
                ScreenManager.Instance.CurrentSpriteBatch.Draw(ImageManager2D.Instance.WhiteBox, Vector2.Zero, transColor);
            }
        }

        

        public enum Transit
        {
            BEGIN,END
        }
    }
}
